package minmax;

/**
 * game could result in draw or win of one of the two players
 * 
 * @author alex
 */
public enum GameOutcome {
	
	Draw, First, Second;
	
	/**
	 * retrieves a winning player, in case if it is not a draw
	 * 
	 * @return the player identifier
	 */
	public boolean player() {
		switch (this) {
		case Draw:
			throw new IllegalStateException("there is no specific player for draw");
		case First:
			return false;
		case Second:
			return true;
		default:
			throw new AssertionError("unknown constant: " + this);
		}
	}
	
	/**
	 * distinguishes between first and second player
	 * 
	 * @param player is the player
	 * @return is an enum constant
	 */
	public static GameOutcome resolve(boolean player) {
		return player ? Second : First;
	}
	
}
